package com.lj.dict.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lj.dict.entity.Dict;
import com.lj.dict.entity.DictItem;
import com.lj.dict.param.DictItemPageParam;
import com.lj.dict.param.DictItemSaveParam;
import com.lj.dict.param.DictItemUpdateParam;
import com.lj.dict.result.DictItemInfoResult;
import com.lj.dict.result.DictItemPageResult;
import com.lj.dict.result.DictItemResult;
import com.lj.mp.standard.StandardService;

import java.util.List;

/**
 * <p>
 * 字典项表 服务类
 * </p>
 *
 * @author luojing
 * @since 2025-01-10 11:16:54
 */
public interface DictItemService extends StandardService<DictItem> {

    IPage<DictItemPageResult> page(DictItemPageParam param);

    DictItemInfoResult info(Long id);

    void save(DictItemSaveParam param);

    void update(DictItemUpdateParam param);

    List<DictItemResult<Object>> getDictItem(Dict dict);

    /**
     * 通过字典id获取该字典下的所有字典项
     *
     * @param dictId 字典id
     * @return 所有的字典项
     */
    default List<DictItem> getByDictId(Long dictId) {
        return list(lambdaQueryWrapper()
                .eq(DictItem::getDictId, dictId)
                .orderByAsc(DictItem::getSort)
        );
    }

    void deleteByDictIds(List<Long> dictIds);
}
